package gps;
import gps.api.GPSEngine;
import gps.api.GPSProblem;
import gps.api.impl.MyGPSEngine;
import gps.api.impl.MyGPSProblem;

public class Main {
	public static void main(String[] args) {
		if (args.length < 1 || args.length > 2) {
			System.out.println("\nUsage: \nstrategy [heuristic]\n\n" +
					"strategy = DFS, BFS, IDS, AStar, Greedy\n" +
					"You can choose one of this parameters of the heuristics combination\n" +
					"1 = ColorCount\n" +
					"2 = Distance remaining to bottom right corner\n" +
					"3 = combination of both\n");
			return;
		}

		SearchStrategy strategy = null;
		if (args[0].equalsIgnoreCase("DFS")) strategy = SearchStrategy.DFS;
		else if (args[0].equalsIgnoreCase("BFS")) strategy = SearchStrategy.BFS;
		else if (args[0].equalsIgnoreCase("IDS")) strategy = SearchStrategy.IDS;
		else if (args[0].equalsIgnoreCase("AStar")) strategy = SearchStrategy.ASTAR;
		else if (args[0].equalsIgnoreCase("Greedy")) strategy = SearchStrategy.GREEDY;
		else { 
			System.err.println(args[0] + " not a valid strategy");
			return;
		}
		
		Heuristic heuristic = Heuristic.None;
		if (args.length == 2) {
			if (args[1].equalsIgnoreCase("1")) heuristic = Heuristic.ColorCount;
			else if (args[1].equalsIgnoreCase("2")) heuristic = Heuristic.FarCluster;
			else if (args[1].equalsIgnoreCase("3")) heuristic = Heuristic.Both;
			else if (args[1].equalsIgnoreCase("4")) heuristic = Heuristic.RemainingSquares;
			else { 
				System.err.println(args[1] + " not a valid heuristic");
				return;
			}
		}
		
		GPSEngine engine = new MyGPSEngine();
		GPSProblem problem = new MyGPSProblem(heuristic);
		
		engine.engine(problem, strategy, heuristic);
	}
}
